package com.juku2024.juku.adapter

import android.text.TextUtils
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.juku2024.juku.R
import com.juku2024.juku.model.CommonModel
import com.juku2024.juku.tools.ImageUtils

import java.util.*

class VideoListAdapter(data: ArrayList<CommonModel>) :
    BaseQuickAdapter<CommonModel, BaseViewHolder>(R.layout.item_home_tab_grid2, data), LoadMoreModule {

    var category = 0

    override fun convert(holder: BaseViewHolder, item: CommonModel) {
        val colorResId: Int
        val update: String
        if (category == 1 && !TextUtils.isEmpty(item.score)) {
            update = item.score!!
            colorResId = R.color.cFF6D2F
        } else {
            update = item.update_progress ?: ""
            colorResId = R.color.cFFFFFF
        }
        holder.setText(R.id.tv_title, item.name)
            .setText(R.id.tv_update, update)
            .setTextColorRes(R.id.tv_update, colorResId)

        val iv = holder.getView<ImageView>(R.id.iv_home)
        ImageUtils.loadImageV(iv, item.pic)
    }

}